package com.ecfront.dao.impl;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ecfront.dao.PayGoodsDAO;
import com.ecfront.pojo.PayGoods;


/**
 * @version 1.0
 * @author www.ecfrom.com
 */

public class PayGoodsDAOImpl extends HibernateDaoSupport implements PayGoodsDAO {
	private static final Log log = LogFactory.getLog(PayGoodsDAOImpl.class);
	protected void initDao() {}

	public void save(PayGoods transientInstance) {
		getHibernateTemplate().saveOrUpdate(transientInstance);
	}

	public void delete(PayGoods persistentInstance) {
		getHibernateTemplate().delete(persistentInstance);

	}

	public PayGoods findById(java.lang.Integer id) {
		PayGoods instance = (PayGoods) getHibernateTemplate().get(
					"com.ecfront.pojo.PayGoods", id);
		return instance;
	}

	public List findByProperty(String propertyName, Object value) {
		String queryString = "from PayGoods as model where model."
					+ propertyName + "= ?";
		return getHibernateTemplate().find(queryString, value);
	}


	public List findByPgPrice(Object pgPrice) {
		return findByProperty(PG_PRICE, pgPrice);
	}

	public List findByPgCount(Object pgCount) {
		return findByProperty(PG_COUNT, pgCount);
	}

	public List findAll() {
		String queryString = "from PayGoods";
		return getHibernateTemplate().find(queryString);
	}

	public static PayGoodsDAO getFromApplicationContext(ApplicationContext ctx) {
		return (PayGoodsDAO) ctx.getBean("PaygoodsDAO");
	}
}